<!DOCTYPE html>
<html>
<head>
<title>AJAX Training</title>
<link rel=stylesheet type=text/css href="style.css">
<script>
var txt = "<table border=1><tr align=center><td><b>Timestamp</b></td><td><b>Node</b></td><td><b>Xval</b></td><td><b>Yval</b></td><td><b>Zval</b></td><td><b>Mval</b></td><td><b>Purged</b></td></tr>";
function loadXMLDoc()
{
var request = new XMLHttpRequest();
request.open("GET", "day9JSON.json", true);
request.setRequestHeader("Content-type", "application/json", true);
request.onreadystatechange = function(){
if(request.readyState == 4 && request.status == 200)
{
var data = JSON.parse(request.responseText);
for(var i in data){
txt += "<tr><td>" + data[i].timestamp + "</td><td>" + data[i].node + "</td><td>" + data[i].xval + "</td><td>" + data[i].yval + "</td><td>" + data[i].zval + "</td><td>" + data[i].mval + "</td><td>" + data[i].purged + "</td></tr>";
}
txt += "</table>";
document.getElementById("result").innerHTML = txt;
}
}
request.send();
}
</script>
</head>
<body onload="loadXMLDoc()">
<center>
<h2>Data from Sensor Nodes</h2>
<div id="result">
</div>
</center>
</body>
</html>